/*
*******************************************************************************
COPYRIGHT 2010 Atech-Automotive
Source File Name : uds_diag_fun.c
Group            : ATECH
Author           :
Date First Issued:
********************************Documentation**********************************
General Purpose - This file contains the function prototypes for the driver fun
-ctions and the Data Types.
********************************RevisionHistory********************************
_______________________________________________________________________________
Date : MM/DD/YY                       Release : V1.0
Date : 05/10/2010                service operation in appl layer

******************************************************************************/

/* #include */
#include "system.h"
#include "uds_diag_appl.h"
#include "uds_diag_read_write_fun.h"
#include "hwa_e2_callback.h"
#include "hwa_e2.h"
#pragma CODE_SEG  OTHER_ROM

#ifdef MODE_22_SUPPORTED

UINT8 Read_Bootloader_SoftwareNumber( UINT8 *p_u8_data, UINT8 u8_length )  //0xF183
{
    UINT8 u8_resp = FALSE;
    (void)u8_length;
    (void)p_u8_data;

//    Diag_UpdateSnapShotStatus();

//    p_u8_data[0] = s_SnapShot.IgnitionStatus;

    u8_resp = TRUE;

    return u8_resp;
}


UINT8 Read_Application_fingerprint( UINT8 *p_u8_data, UINT8 u8_length )  //0xF184
{
    UINT8 u8_resp = FALSE;
    (void)u8_length;
    (void)p_u8_data;

//    Diag_UpdateSnapShotStatus();

//    p_u8_data[0] = s_SnapShot.IgnitionStatus;
    hwa_e2ReadDataById( E2_ADDR_ECU_APPFINGER_NUM_1,&p_u8_data[0]);
    hwa_e2ReadDataById( E2_ADDR_ECU_APPFINGER_NUM_2,&p_u8_data[4]);
	hwa_e2ReadDataById( E2_ADDR_ECU_APPFINGER_NUM_3,&p_u8_data[8]);

    u8_resp = TRUE;

    return u8_resp;
}

UINT8 Read_System_Supplier_ECU_SoftwareNumber( UINT8 *p_u8_data, UINT8 u8_length )  //0xF187
{
    UINT8 u8_resp = FALSE;
    (void)u8_length;
    (void)p_u8_data;

//    Diag_UpdateSnapShotStatus();

//    p_u8_data[0] = s_SnapShot.IgnitionStatus;
    p_u8_data[0] = 'E';
    p_u8_data[1] = '0';
    p_u8_data[2] = '0';
    p_u8_data[3] = '1';
    p_u8_data[4] = '0';
    p_u8_data[5] = '9';
    p_u8_data[6] = '8';
    p_u8_data[7] = '7';
    p_u8_data[8] = '5';


    u8_resp = TRUE;

    return u8_resp;
}

UINT8 Read_SupplierIdentifierDataIdentifier( UINT8 *p_u8_data, UINT8 u8_length )  //0xF18A
{
    UINT8 u8_resp = FALSE;
    (void)u8_length;
    (void)p_u8_data;

//    Diag_UpdateSnapShotStatus();

//    p_u8_data[0] = s_SnapShot.IgnitionStatus;
    p_u8_data[0] = 'Z';
    p_u8_data[1] = '5';
    p_u8_data[2] = '5';
    p_u8_data[3] = '3';
    p_u8_data[4] = 'W';
    p_u8_data[5] = '2';
    p_u8_data[6] = '0';
    p_u8_data[7] = '0';
    p_u8_data[8] = '0';
    p_u8_data[9] = '1';


    u8_resp = TRUE;

    return u8_resp;
}

UINT8 Read_VehicleIdentificationNumber( UINT8 *p_u8_data, UINT8 u8_length )  //0xF190
{
    UINT8 u8_resp = FALSE;
    (void)u8_length;
    (void)p_u8_data;

//    Diag_UpdateSnapShotStatus();

//    p_u8_data[0] = s_SnapShot.IgnitionStatus;
    hwa_e2ReadDataById( E2_ADDR_VIN_NUM_1,&p_u8_data[0]);
    hwa_e2ReadDataById( E2_ADDR_VIN_NUM_2,&p_u8_data[4]);
	hwa_e2ReadDataById( E2_ADDR_VIN_NUM_3,&p_u8_data[8]);
	hwa_e2ReadDataById( E2_ADDR_VIN_NUM_4,&p_u8_data[12]);
	hwa_e2ReadDataById( E2_ADDR_VIN_NUM_5,&p_u8_data[16]);
    u8_resp = TRUE;

    return u8_resp;
}

UINT8 Read_VehicleManufacturerECUHwVersionNumber( UINT8 *p_u8_data, UINT8 u8_length )  //0xF191
{
    UINT8 u8_resp = FALSE;
    (void)u8_length;
    (void)p_u8_data;

//    Diag_UpdateSnapShotStatus();

//    p_u8_data[0] = s_SnapShot.IgnitionStatus;
    p_u8_data[0] = 'H';
    p_u8_data[1] = '0';
    p_u8_data[2] = '0';
    p_u8_data[3] = '1';
    p_u8_data[4] = '-';
    p_u8_data[5] = 'H';
    p_u8_data[6] = '0';
    p_u8_data[7] = '0';
    p_u8_data[8] = '1';


    u8_resp = TRUE;

    return u8_resp;
}

UINT8 Read_SysSupplierECUSoftwareVNIdentifier( UINT8 *p_u8_data, UINT8 u8_length )  //0xF195
{
    UINT8 u8_resp = FALSE;
    (void)u8_length;
    (void)p_u8_data;

//    Diag_UpdateSnapShotStatus();

//    p_u8_data[0] = s_SnapShot.IgnitionStatus;
    p_u8_data[0] = ' ';
    p_u8_data[1] = 'S';
    p_u8_data[2] = '0';
    p_u8_data[3] = '0';
    p_u8_data[4] = '1';
    p_u8_data[5] = 'C';
    p_u8_data[6] = '0';
    p_u8_data[7] = '0';
    p_u8_data[8] = '1';


    u8_resp = TRUE;

    return u8_resp;
}

#endif  /* MODE_22_SUPPORTED */

#ifdef MODE_2E_SUPPORTED

UINT8 WR_Application_fingerprint( UINT8 *p_u8_data, UINT8 u8_length )
{
    UINT8 u8_resp = FALSE;

//    if( isBasicCFGValid( p_u8_data ) == TRUE )
//    {
//        UdsAppl_WriteE2ByPara( DIAG_E2_ADDR_Basic_CFG, u8_length, p_u8_data );
//        u8_resp = TRUE;
//    }
    UdsAppl_WriteE2ByPara( DIAG_E2_ADDR_Application_Fingerprint_INFOR, u8_length, p_u8_data );
    (void)p_u8_data;
    (void)u8_length;
	u8_resp = TRUE;
    return u8_resp;
}

UINT8 WR_VehicleIdentificationNumber( UINT8 *p_u8_data, UINT8 u8_length )
{
    UINT8 u8_resp = FALSE;

//    if( isBasicCFGValid( p_u8_data ) == TRUE )
//    {
//        UdsAppl_WriteE2ByPara( DIAG_E2_ADDR_Basic_CFG, u8_length, p_u8_data );
//        u8_resp = TRUE;
//    }

	UdsAppl_WriteE2ByPara( DIAG_E2_ADDR_VIN, u8_length, p_u8_data );

    (void)p_u8_data;
    (void)u8_length;
	u8_resp = TRUE;
    return u8_resp;
}

#endif  /* MODE_2E_SUPPORTED */

#pragma CODE_SEG DEFAULT